#ifndef _DS_ALGORITHM_H
#define _DS_ALGORITHM_H

extern double fibonacci(double i);
extern double fibonacci_r(double i);

/*
 * Count the number of combination
 * it's just the result of C(n,r)
 * precondition: n >= r >= 0
 */
extern int combination_r(int n, int r);

/*
 * divided n into smaller repeatable numbers which is smaller than m
 * for number 6:
 * 6
 * 5+1
 * 4+2  4+1+1
 * 3+3 3+2+1 3+1+1+1
 * just return the number
 */
extern int split_int(int n, int m);

/*
 * Generate permutation 
 * algorithm:
 * 1) find i : i = max{j | a[j-1] < a[j]}
 * 2) find h : h = max{j | a[i-1] < a[j]}
 * 3) swap a[i-1], a[h]
 * 4) reverse a[i] ... a[n] (method reverse())
 * tip: make sure the queue is sequential
 * and this method is just for integers 
 */
extern void reverse(int *a, int n);
extern void permutations(int *a, int n);


#endif
